<!-- 
此组件初始化时不会自动加载数据，请在mounted中 this.$refs.[].initData()
如果放在dialog里面的吗，请在dialog的open事件中用this.$nextTick进行加载
 -->
<template>
  <div>
    <list
      id-key="id"
      ref="list"
      unit="用户"
      :disabled="disabled"
      :show-query="showQuery"
      show-checkbox
      :query-params="queryParams"
      :expand-query="expandQuery"
      :show-summary="showSummary"
      :page="page"
      :get-page-list-func="api.getPageList"
      :delete-func="api.deleteById"
    >
      <template #toolbar-left>
        <slot name="toolbar-left"></slot>
      </template>
      <template #query>
        <!-- <el-form-item label="ID">
          <el-input v-model.trim="queryParams.id" clearable></el-input>
        </el-form-item> -->
        <div>
          <el-form-item label="用户名">
            <el-input
              v-model.trim="queryParams.userName"
              placeholder="用户名"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item label="英文名">
            <el-input
              v-model.trim="queryParams.name"
              placeholder="英文名"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item label="中文名">
            <el-input
              v-model.trim="queryParams.cName"
              placeholder="中文名"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item label="邮箱">
            <el-input
              v-model.trim="queryParams.emailAddress"
              placeholder="邮箱"
              clearable
            ></el-input>
          </el-form-item>
        </div>
        <div>
          <el-form-item label="用户ID">
            <el-input
              v-model="queryParams.idString"
              placeholder="用户ID，以,或空格分隔"
              clearable
              style="width:800px;max-width:none"
            ></el-input>
          </el-form-item>
        </div>
      </template>
      <template #column>
        <el-table-column
          prop="id"
          width="80"
          label="ID"
        >
          <template #default="{row}">
            <span
              class="c-link"
              @click="openDetail(row.id)"
            >{{row.id}}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="userName"
          label="用户名"
        >
          <template #default="{row}">
            {{row.userName}}<el-tag
              v-if="row.isDeleted"
              type="danger"
            >删除</el-tag>
          </template>
        </el-table-column>
        <el-table-column
          prop="name"
          width="180"
          label="英文名"
        >

        </el-table-column>
        <el-table-column
          prop="cName"
          width="180"
          label="中文名"
        >
        </el-table-column>
        <el-table-column
          prop="emailAddress"
          width="200"
          label="邮箱"
        >
        </el-table-column>
        <el-table-column
          prop="phoneNumber"
          width="180"
          label="手机"
        >
        </el-table-column>
        <el-table-column
          prop="isValid"
          align="center"
          width="80"
          label="有效性"
        >
          <template #default="{row}">
            <el-tag
              v-if="row.isValid"
              type="success"
            >有效</el-tag>
            <el-tag
              v-else
              type="danger"
            >无效效</el-tag>
          </template>
        </el-table-column>
        <el-table-column
          prop="creatorUserName"
          width="100"
          label="创建人"
          show-overflow-tooltip
        />
        <el-table-column
          prop="creationTime"
          width="120"
          label="创建时间"
          sortable="custom"
        >
          <template v-slot="{ row }">
            <span>{{ row.creationTime | toShortDatetimeString }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="lastModificationTime"
          width="120"
          label="修改时间"
          sortable="custom"
        >
          <template v-slot="{ row }">
            <span>{{ row.lastModificationTime | toShortDatetimeString }}</span>
          </template>
        </el-table-column>
        <!-- slot[column] -->
        <slot name="column"></slot>
        <!--/ slot[column]-->
      </template>
    </list>
    <detail-dialog ref="detailDialog" />
  </div>
</template>
<script>
import listMixin from "@/mixins/list";
import list from "@/components/common/list";
import detailDialog from "./detailDialog";
import api from "@/api/sso/user";
export default {
  mixins: [listMixin],
  components: {
    list,
    detailDialog
  },
  props: {},
  data() {
    return {
      //查询条件字段
      queryParams: {
        invoiceNo: "",
        invoiceCode: "",
        serialNo: "",
        buyerTitleName: "",
        sellerTitleName: "",
        statuses: [],
      },
      api,
    };
  },
  methods: {
    getStatusType(status) {
      var text = "";
      switch (status) {
        case 0:
          text = "info";
          break;
        case 1:
          text = "";
          break;
        case 2:
          //作废
          text = "info";
          break;
        case 3:
          //冲红
          text = "warning";
          break;
        case 6:
          text = "danger";
          break;
      }
      return text;
    },
    openInvoice(url) {
      window.open(url);
    },
    openDetail(id) {
      this.$refs.detailDialog.openDetail(id);
    }
  },
};
</script>